package com.wnhz.work.jy.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.wnhz.work.jy.BaseActivity;
import com.wnhz.work.jy.R;
import com.wnhz.work.jy.adapter.AuctionAdapter;
import com.wnhz.work.jy.bean.AuctionBean;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * ---拍卖
 */
public class AuctionActivity extends BaseActivity implements View.OnClickListener {
    private TextView title;
    private ListView listView;
    private AuctionAdapter mAdapter;

    private List<AuctionBean> auctionList = new ArrayList<>();

    @ViewInject(R.id.include_occupied)
    private View include_occupied;
    @ViewInject(R.id.blank_img)
    private ImageView blank_img;
    @ViewInject(R.id.blank_tv)
    private TextView blank_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_auction);
        x.view().inject(this);

        //initData();
        initView();
        setBlank();
    }

    private void setBlank() {
        if (auctionList.size() == 0) {
            blank_tv.setText("暂时没有新的拍卖品上架~");
            blank_img.setImageResource(R.mipmap.ic_kongpaimai);
            include_occupied.setVisibility(View.VISIBLE);
        } else {
            include_occupied.setVisibility(View.GONE);
        }
    }


    private void initView() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("拍卖");
        findViewById(R.id.btn_main_left).setOnClickListener(this);

        listView = (ListView) findViewById(R.id.lv_auction);

        mAdapter = new AuctionAdapter(AuctionActivity.this, auctionList, this);
        listView.setAdapter(mAdapter);

    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.btn_main_left:
                finish();
                break;

            //点击立即抢拍
            case R.id.tv_rob:
                intent = new Intent(AuctionActivity.this, GetSellCoin.class);
                startActivity(intent);
                break;

            default:
                break;
        }
    }
}
